package it.xiuxian.personcenter.activity

import android.widget.LinearLayout
import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.github.yoojia.inputs.AndroidNextInputs
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.tencent.mm.opensdk.openapi.IWXAPI
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import it.xiuxian.lib.base.*
import it.xiuxian.lib.http.SPConfig
import it.xiuxian.lib.utils.*
import it.xiuxian.personcenter.R
import it.xiuxian.personcenter.bean.Constant
import it.xiuxian.personcenter.bean.Datap
import it.xiuxian.personcenter.databinding.ActivityShimingBinding
import it.xiuxian.personcenter.presenter.ShiMingActivityPresenter
@Route(path = ArouterAddress.SHIMINGACTIVITY)
class ShiMingActivity:BaseActivity<ShiMingActivityPresenter>() {
   lateinit var binding:ActivityShimingBinding
    var inputs: AndroidNextInputs?=null
    override val layoutId: Int
        get() = R.layout.activity_shiming
    override val presenter: ShiMingActivityPresenter
        get() = ShiMingActivityPresenter()

    override fun initView() {
        setTitle("实名认证")
        ARouter.getInstance().inject(this)
        AppManager.getSingleton().addActivity(this)
        binding=  getViewDataBinding<ActivityShimingBinding>()

        inputs = ToastNextInputs()
        inputs!!.clear()
        inputs!!.add(binding.etPass, SchemeUtil.notEmpty(binding.etPass))
        //inputs!!.add(binding.etXin, SchemeUtil.notEmpty(binding.etXin))
        (binding.include.re.layoutParams as LinearLayout.LayoutParams).setMargins(0,
            DensityUtil.getStatusPix(App.INSTANCE.applicationContext)+5,0,0)
        binding.include.tvTitle.setTextColor(resources.getColor(R.color.lib_view))
        binding.include.leftImg.setColorFilter(resources.getColor(R.color.lib_view))
        binding.etPass.setHint(EditHintUtils.setHintSizeAndContent("请输入真实姓名",14,true))
        binding.etXin.setHint(EditHintUtils.setHintSizeAndContent("请输入身份证号",14,true))
        binding.tvSure.setOnClickListener {
            if(inputs!!.test()){
                ARouter.getInstance().build(ArouterAddress.FACEACTIVITY).withString("name",binding.etPass.text.toString()).navigation()
               /* SPUtil.get(SPConfig.PHONE,"")?.let { it1 ->
                    mPresenter!!.yanzheng("ZdS6tcUDkoWfMIuI",System.currentTimeMillis().toString(),
                        MD5Utils.md5("ZdS6tcUDkoWfMIuI"+"&"+System.currentTimeMillis().toString()+"&"+"ZdS6tcUDkoWfMIuIbGTEvwXHBBe35z6o"),binding.etPass.text.toString(),binding.etXin.text.toString(),
                        it1
                    )
                }*/
            }


        }
    }

    /*private fun regToWx() {
        // 通过WXAPIFactory工厂，获取IWXAPI的实例
        api = WXAPIFactory.createWXAPI(requireActivity(), APP_ID, true)

        // 将应用的appId注册到微信
        api!!.registerApp(APP_ID)

        //建议动态监听微信启动广播进行注册到微信
       requireActivity().registerReceiver(object : BroadcastReceiver() {
          override  fun onReceive(context: Context?, intent: Intent?) {

                // 将该app注册到微信
                api!!.registerApp(Constant.APP_ID)
            }
        }, IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP))
    }*/

    fun setUI(data: String) {
       /* SPUtil.get(SPConfig.SESSION_ID,"")?.let {
            mPresenter!!.getRenzheng(binding.etPass.text.toString(),binding.etXin.text.toString(),
                it
            )
        }*/
    }

    override fun initData() {

        //super.initData()
       // SPUtil.get(SPConfig.SESSION_ID,"")?.let { mPresenter!!.shiming("1", it) }
    }
    fun setData(msg: String) {
    /*   Toast.makeText(this,msg,Toast.LENGTH_SHORT).show()
        ARouter.getInstance().build(ArouterAddress.FACEACTIVITY).withString("idcard",binding.etXin.text.toString()).withString("name",binding.etPass.text.toString()).navigation()*/
    }
}